#ifndef _CONFIG_PARSE_
#define _CONFIG_PARSE_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

    typedef enum _config_type_file
    {
        config_type_unknow = 0,
        config_type_xml,
        config_type_json,
        config_type_yml,
        config_type_ini
    } config_type_file;

    typedef struct _conf_node {
        char *name;
        char *value;
        struct _conf_node *next;
        struct _conf_node *first_child;
    } conf_node_t;

    typedef struct _config {
        int ncase;
        conf_node_t *first_node;
    } config_t;

    int config_open(config_t** conf, config_type_file type, const char* file);
    int config_parse(config_t** conf, config_type_file type, const char* data, int size);
    void config_close(config_t *conf);
    int config_ncase(config_t *conf, int ncase);

    char* config_get_string(config_t *conf, char *path, char *default_value);
    int32_t config_get_int(config_t *conf, char *path, int32_t default_value);
    int64_t config_getint64(config_t *conf, char *path, int64_t default_value);
    float config_get_float(config_t *conf, char *path, float default_value);
    double config_get_double(config_t *conf, char *path, double default_value);

#ifdef __cplusplus
}
#endif
#endif